import { da } from 'element-plus/es/locale/index.mjs'
import axios from '~/axios'

export function login(username, password) {
  return axios.post(
    '/api/v1/login/token',
    {
      account: username,
      password: password
    },
    {
      needToken: false
    }
  )
}
export function addUser(data){
  return axios.post(
    '/api/v1/user/create',
    {
      account: data.username,
      password: data.password,
      email: data.email
    },
    {
      needToken: false
    }
  )
}

export function getinfo() {
  return axios.get('/api/v1/user/me', { needToken: true })
}

export function logout() {
  return axios.post('/api/v1/user/logout', {}, { needToken: true })
}

export function updatePassword(data) {
  return axios.post('/api/v1/user/updatepassword', data, { needToken: true })
}

// 聊天模型部分
export function ChatModelList(data){
  return axios.post('/api/v1/chat/list', data, { needToken: true })
}
export function ChatCreateSession(data){
  return axios.post('/api/v1/chat/create_session', data, { needToken: true })
}

export function ChatSessionList(data){
  return axios.post('/api/v1/chat/session_list', data, { needToken: true })
}

export function ChatDialogueList(data){
  return axios.post('/api/v1/chat/dialogue', data, { needToken: true })
}

export function ChatAnswer(data){
  return axios.post('api/v1/chat/chat', data, { needToken: true })
}

export function ChatSaveSession(data){
  return axios.post('/api/v1/chat/update_session', data, { needToken: true })
}
export function ChatDeleteSession(session_id){
  return axios.delete('/api/v1/chat/session', {params: {session_id: session_id}, needToken: true }, {})
}

export function ChatCreateSessionConfig(data){
  return axios.post('/api/v1/chat/create_session_config', data, { needToken: true })
}



// 绘图模型部分
export function DrawModelList(data){
  return axios.post('/api/v1/draw/list', data, { needToken: true })
}
export function DrawCreateSession(data){
  return axios.post('/api/v1/draw/create_session', data, { needToken: true })
}

export function DrawSessionList(data){
  return axios.post('/api/v1/draw/session_list', data, { needToken: true })
}

export function DrawDialogueList(data){
  return axios.post('/api/v1/draw/dialogue', data, { needToken: true })
}

export function DrawAnswer(data){
  return axios.post('api/v1/draw/draw', data, { needToken: true })
}

export function DrawSaveSession(data){
  return axios.post('/api/v1/draw/update_session', data, { needToken: true })
}
export function DrawDeleteSession(session_id){
  return axios.delete('/api/v1/draw/session', {params: {session_id: session_id}, needToken: true }, {})
}
export function SessionConfig(session_id){
  return axios.get('/api/v1/chat/session_config', {params: {session_id: session_id}, needToken: true })
}


// 知识库部分
export function KnowledgeList(data){
  return axios.post('/api/v1/knowledge/list', data, { needToken: true })
}


export function KnowledgeCreate(data){
  return axios.post('/api/v1/knowledge/create', data, { needToken: true })
}

export function KnowledgeInfo(knowledge_id){
  return axios.get('/api/v1/knowledge/info', {params: {knowledge_id: knowledge_id}, needToken: true })
}

export function KnowledgeFileList(data){
  return axios.post('/api/v1/knowledge/file_list', data, { needToken: true })
}

export function KnowledgeFileDelete(knowledge_id, file_id){
  return axios.delete('/api/v1/knowledge/knowledge_file', {params: {knowledge_id: knowledge_id, file_id: file_id}, needToken: true })
}


export function KnowledgeFileUpload(file, knowledge_id) {
  const formData = new FormData();
  formData.append('file', file); // 添加文件
  return axios.post('/api/v1/knowledge/upload', formData, {
    params: { knowledge_id: knowledge_id }, // 添加查询参数
    needToken: true, // 自定义配置，用于请求拦截器
  });
}

export function KnowledgeFileHandle(data){
  return axios.post('/api/v1/knowledge/handle', data, { needToken: true })
}

export function AllKnowledge(){
  return axios.get('/api/v1/knowledge/all', { needToken: true })
}

export function KnowledgeDelete(knowledge_id){
  return axios.delete('/api/v1/knowledge/delete', {params: {knowledge_id: knowledge_id}, needToken: true })
}


// 向量服务部分
export function EmbeddingServer(data){
  return axios.post('/api/v1/embedding_server/list', data, { needToken: true })
}

// 文本内容抽取服务部分
export function TextExtractionServer(data){
  return axios.post('/api/v1/file_extract/list', data, { needToken: true })
}

